﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace @for
{
    class Program
    {
        static void Main(string[] args)
        {
            int s = 0;
            Console.WriteLine("请输入一个自然数");
            int iMax = Convert.ToInt32(Console.ReadLine());//获取字符串并转换为整形
            for (int i=1;i<=iMax;i++){
                s +=i;
            }
            Console.WriteLine("1+2+3+...+{0}={1}",iMax,s);

            s = 0;
            int ii=1;
            while(ii<=iMax){
                s+=ii;
                ii++;
            }
            Console.WriteLine("1+2+3+...+{0}={1}", iMax, s);

            s = 0;
            ii = 1;
            do{
                s+=ii;
                ii++;

            }while(ii<=iMax);
            Console.WriteLine("1+2+3+...+{0}={1}",iMax,s);
            Console.ReadKey();
        }
    }
}
